package com.bocai.controller;

import com.bocai.bean.MessageInfo;
import com.bocai.service.IMessageInfoService;
import com.bocai.utils.CodeEnum;
import com.bocai.utils.ResponseData;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * Created by jyf on 18/4/11.
 */
@Controller
@RequestMapping("messageInfo")
public class MessageInfoController {

    @Autowired
    IMessageInfoService messageInfoService;

    @ApiOperation(value = "查询消息列表  传用户Id 代表查看所有未读消息", notes = "查询消息列表  传用户Id 代表查看所有未读消息")
    @RequestMapping(value = "/findAllMessageInfo", method = RequestMethod.GET)
    @ResponseBody
    public ResponseData findAllMessage(Integer userId) {
        ResponseData data = new ResponseData();
        data.setCodeEnum(CodeEnum.SUCCESS);
        data.setResults(messageInfoService.selectAll(userId));
        return data;
    }

    @ApiOperation(value = "查询消息", notes = "查询消息")
    @RequestMapping(value = "/findMessageInfo", method = RequestMethod.GET)
    @ResponseBody
    public ResponseData findMessageInfo(Integer messageId) {
        ResponseData data = new ResponseData();
        data.setCodeEnum(CodeEnum.SUCCESS);
        data.setResults(messageInfoService.selectMessageInfo(messageId));
        return data;
    }

}
